<!-- @Author: Yu_Bo -->
<template>
	<view class="goods_list">
		<view class="list" :class="type==2?'list_bg':''" v-for="(item,index) in list" :key="index" @click="details(item)">
			<view class="img">
				<image :src="item.image" mode="aspectFill"></image>
			</view>
			<view class="info">
				<view class="title line_one">
					{{item.goods_name}}
				</view>
				<view class="txt line_one">
					{{item.author}}/{{item.press}}
				</view>
				<view class="tip line_one">
					{{item.label}}
				</view>
				<view class="money">
					<view class="left">
						<text class="icon">￥</text>
						<text class="num">{{item.past_sale_price}}</text>
						<text class="zhe color1">二手{{item.past_discount}}折</text>
					</view>
				</view>
				<view class="money">
					<view class="left">
						<text class="icon">￥</text>
						<text class="num">{{item.new_sale_price}}</text>
						<text class="zhe color2">新书{{item.new_discount}}折</text>
					</view>
				</view>
			</view>
			<!--  -->
			<view class="list_btn" @click.stop="addBtn(item)">
				买这本书
			</view>
		</view>
		<!-- sku -->
		<c-booksku ref="sku" :safearea="type==1?false:true"></c-booksku>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			type: {
				type: Number,
				default: 1
			},
			list: {
				type: Array,
				default: () => []
			}
		},
		data() {
			return{
				
			}
		},
		computed: {},
		mounted() {},
		methods: {
			// 详情
			details(item) {
				this.$navToLogin("/pagesHome/details/index?id="+item.goods_id)
			},
			// 买这本书
			addBtn(item) {
				var arr = [
					{
						type: 0,
						id: item.goods_id,
						price: item.past_sale_price,
						discount: item.past_discount,
						label: item.past_label,
						num: item.past_book_num,
					},
					{
						type: 1,
						id: item.goods_id,
						price: item.new_sale_price,
						discount: item.new_discount,
						label: item.new_label,
						num: item.new_book_num,
					}
				]
				this.$refs.sku.openBtn(item.goods_name,arr)
			},
		},
	}
</script>

<style lang='scss' scoped>
	.goods_list {
		width: 100%;
		
		.list {
			position: relative;
			width: 100%;
			padding: 20rpx;
			margin-bottom: 30rpx;
			background: #fff;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			
			.img {
				width: 180rpx;
				height: 240rpx;
				
				image {
					display: block;
					width: 100%;
					height: 100%;
				}
			}
			
			.info {
				width: calc(100% - 180rpx);
				height: 240rpx;
				padding-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				
				.title {
					width: 100%;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #222222;
				}
				
				.txt {
					width: 100%;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
				}
				
				.tip {
					width: 100%;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #00A8FF;
				}
				
				.money {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					
					.left {
						display: flex;
						align-items: center;
						
						.icon {
							padding-top: 5rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 24rpx;
							color: #5A68FF;
						}
						
						.num {
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 36rpx;
							color: #5A68FF;
						}
						
						.zhe {
							margin-left: 20rpx;
							padding: 2rpx 10rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 22rpx;
							background: #fff;
							border-radius: 10rpx;
						}
						
						.color1 {
							color: #57CB82;
							border: 2rpx solid #57CB82;
						}
						
						.color2 {
							color: #FF9400;
							border: 2rpx solid #FF9400;
						}
					}
					
					.right {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
					}
				}
			}
			
			.list_btn {
				position: absolute;
				bottom: 20rpx;
				right: 20rpx;
				width: 160rpx;
				height: 60rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #FFFFFF;
				background: #5A68FF;
				border-radius: 30rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
		
		.list:last-child {
			margin-bottom: 0;
		}
		
		.list_bg {
			background: #f6f6f6;
		}
	}
</style>